//
//  JYBaseView.swift
//  JYCalculate
//
//  Created by 何治军 on 2018/10/27.
//  Copyright © 2018 何治军. All rights reserved.
//

import UIKit

class JYBaseView: UIView {
    
    ///添加控件
    func setUpUI(){
        self.addSubview(self.topLine)
        self.addSubview(self.bottomLine)
    }
    
    ///设置界面约束
    func setTheConstraints() {
        topLine.mas_updateConstraints { (make) in
            make?.top.mas_equalTo()(self)
            make?.centerX.mas_equalTo()(self)
            make?.width.mas_equalTo()(self)?.multipliedBy()(1)
            make?.height.mas_equalTo()(0.5)
        }
        bottomLine.mas_updateConstraints { (make) in
            make?.bottom.mas_equalTo()(self)
            make?.centerX.mas_equalTo()(self)
            make?.width.mas_equalTo()(self)?.multipliedBy()(1)
            make?.height.mas_equalTo()(0.5)
        }
    }
    
    convenience init() {
        self.init(frame: CGRect())
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpUI()
        self.backgroundColor = JYVCBackGroundColor
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override class var requiresConstraintBasedLayout :Bool {
        get{
            return true
        }
    }
    
    override func updateConstraints() {
        super.updateConstraints()
        setTheConstraints()
    }
    
    //MARK: - lazy
    
    /// 上边分割线（默认隐藏）
    lazy var topLine:UIView = {
        let v = UIView()
        v.backgroundColor = JYDetailGrayColor
        v.isHidden = true
        return v
    }()
    
    /// 底部分割线
    lazy var bottomLine:UIView = {
        let v = UIView()
        v.backgroundColor = JYDetailGrayColor
        return v
    }()

}
